package com.chezhujie.www.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chezhujie.www.domain.Identitycard;
import com.chezhujie.www.persistence.IdentitycardMapper;
import com.xy.core.exception.ClassCheckException;
import com.xy.user.base.service.BaseService;


/**
 * 认证信息
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class IdentitycardService extends BaseService<Identitycard>{
    @Autowired
    private IdentitycardMapper identitycardMapper;

    @Autowired
    public void setBaseMapper(IdentitycardMapper identitycardMapper) {
        this.baseMapper = identitycardMapper;
    }


    public void checkEntity(Identitycard identitycard) throws ClassCheckException {
        if(identitycard.getIdentitycardId()!=null&&identitycard.getIdentitycardId().length()>255){
            throw new ClassCheckException("认证信息主键不能超过255个字符");
        }
        if(identitycard.getUserInfoId()!=null&&identitycard.getUserInfoId().length()>255){
            throw new ClassCheckException("认证信息用户ID不能超过255个字符");
        }
        if(identitycard.getName()!=null&&identitycard.getName().length()>255){
            throw new ClassCheckException("认证信息真实姓名不能超过255个字符");
        }
        if(identitycard.getIdCard()!=null&&identitycard.getIdCard().length()>255){
            throw new ClassCheckException("认证信息身份证号码不能超过255个字符");
        }
        if(identitycard.getIdCardFace()!=null&&identitycard.getIdCardFace().length()>255){
            throw new ClassCheckException("认证信息身份证正面不能超过255个字符");
        }
        if(identitycard.getIdCardReverse()!=null&&identitycard.getIdCardReverse().length()>255){
            throw new ClassCheckException("认证信息身份证背面不能超过255个字符");
        }
    }
    public void checkListEntity(List<Identitycard> listIdentitycard) throws ClassCheckException {

        for (Identitycard identitycard : listIdentitycard) {
            checkEntity(identitycard);
        }

    }
}
